<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="close"
    cancelText="关闭">
    <a-card :bordered="false">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->

      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <a-button @click="add" type="primary" icon="plus">添加选项</a-button>
      </div>

      <!-- table区域-begin -->
      <div>

        <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
          class="j-table-force-nowrap"
          @change="handleTableChange">

          <span slot="action" slot-scope="text, record">
            <a @click="handleEdit(record)">编辑</a>
            <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
          </span>

        </a-table>
      </div>

      <fee-item-modal ref="modalForm" @ok="modalFormOk"></fee-item-modal>
    </a-card>
  </j-modal>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import FeeItemModal from './modules/FeeItemModal'

  export default {
    name: 'FeeItemList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      FeeItemModal
    },
    data () {
      return {
        description: '收费设置-子表管理页面',
        // 表头
        columns: [
          {
            title:'价格(金币/条)',
            align:"center",
            dataIndex: 'value'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/system/feeItem/list",
          delete: "/system/feeItem/delete",
          deleteBatch: "/system/feeItem/deleteBatch",
          exportXlsUrl: "/system/feeItem/exportXls",
          importExcelUrl: "system/feeItem/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
        disableMixinCreated:true,
        parentId:'',
        title:'',
        width:800,
        visible: false,
        disableSubmit: true
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initData(parentId){
        this.parentId=parentId;
        this.visible=true;
        this.queryParam.parentId=parentId;
        this.loadData();
      },
      add: function () {
        this.$refs.modalForm.add({parentId:this.parentId});
        this.$refs.modalForm.title = "新增";
        this.$refs.modalForm.disableSubmit = false;
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'value',text:'值',dictCode:''})
        fieldList.push({type:'string',value:'parentId',text:'父级id',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>